﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using System.Text;


namespace zlh.banganyemian
{
    public partial class banlianxifangshi : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["color"] == "1")
            {
                Page.Theme = "1";

            }
            else if (Session["color"] == "2")
            {
                Page.Theme = "2";
            }
            else
            {
                Page.Theme = "3";
            }
        }

        protected void update_Click(object sender, EventArgs e)
        {
             StringBuilder sb = new StringBuilder(1024);
            sb.Append("UPDATE  stulianxifshi ");
            sb.Append("SET         stuNo = @stuNo, stuName = @stuName,  telephone = @telephone, duanhao = @duanhao, qqnumber = @qqnumber, weixinnumber = @weixinnumber");           
            sb.Append("WHERE   (stuNo = @stuNo) ");

            SqlParameter[] pms = new SqlParameter[6];
            pms[0] = new SqlParameter("@stuNo", this.stuno.Text);
            pms[1] = new SqlParameter("@stuName", this.stuname.Text);
            pms[2] = new SqlParameter("@telephone", longtxt.Text);
            pms[3] = new SqlParameter("@duanhao", this.duanxt.Text);
            pms[4] = new SqlParameter("@qqnumber", this.qqtxt.Text);
            pms[5] = new SqlParameter("@weixinnumber", this.weitxt.Text);
           

            int intResult = SqlHelper.ExecuteNonQuery(sb.ToString(), pms);
            this.lblInfo.Text = (intResult < 1) ? "更新失败！" : "更新" + intResult.ToString() + "条记录！";
        }

        protected void delete_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder(1024);
            sb.Append("DELETE FROM stulianxifshi ");
            sb.Append("WHERE   (stuNo = @stuNo) ");

            SqlParameter[] pms = new SqlParameter[6];
            pms[0] = new SqlParameter("@stuNo", this.stuno.Text);
            pms[1] = new SqlParameter("@stuName", this.stuname.Text);
            pms[2] = new SqlParameter("@telephone", longtxt.Text);
            pms[3] = new SqlParameter("@duanhao", this.duanxt.Text);
            pms[4] = new SqlParameter("@qqnumber", this.qqtxt.Text);
            pms[5] = new SqlParameter("@weixinnumber", this.weitxt.Text);

            int intResult = (int)SqlHelper.ExecuteNonQuery(sb.ToString(), pms);
            this.lblInfo.Text = (intResult < 1) ? "删除失败！" : "删除" + intResult.ToString() + "条记录！";
        }

        protected void add_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder(1024);
            sb.Append("INSERT INTO stulianxifshi ");
            sb.Append("                (stuNo, stuName, telephone, duanhao, qqnumber,weixinnumber) ");
            sb.Append("VALUES   (stuNo = @stuNo, stuName = @stuName,  telephone = @telephone, duanhao = @duanhao, qqnumber = @qqnumber, weixinnumber = @weixinnumber) ");

            SqlParameter[] pms = new SqlParameter[6];
            pms[0] = new SqlParameter("@stuNo", this.stuno.Text);
            pms[1] = new SqlParameter("@stuName", this.stuname.Text);
            pms[2] = new SqlParameter("@telephone", longtxt.Text);
            pms[3] = new SqlParameter("@duanhao", this.duanxt.Text);
            pms[4] = new SqlParameter("@qqnumber", this.qqtxt.Text);
            pms[5] = new SqlParameter("@weixinnumber", this.weitxt.Text);
           
          
            int intResult = (int)SqlHelper.ExecuteNonQuery(sb.ToString(), pms);
            this.lblInfo.Text = (intResult < 1) ? "新增失败！" : "新增" + intResult.ToString() + "条记录！";
        }

        protected void readbtn_Click(object sender, EventArgs e)
        {
            string strSql = "SELECT   stuNo, stuName, telephone, duanhao, qqnumber,weixinnumber FROM      stulianxifshi WHERE   (stuNo = @stuNo)";
            SqlParameter[] pms = new SqlParameter[1];
            pms[0] = new SqlParameter("@stuNo", this.stuno.Text);
            SqlDataReader dr = SqlHelper.ExecuteReader(strSql, pms);
            if (dr.Read())
            {
                this.stuname.Text = dr["stuName"].ToString();
                this.longtxt.Text = dr["telephone"].ToString();
                this.duanxt.Text = dr["duanhao"].ToString();
                this.qqtxt.Text = dr["qqnumber"].ToString();
                this.weitxt.Text = dr["weixinnumber"].ToString();
                
            }
            dr.Close();//关闭
        }
        }

        

       
    }
